using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Data;
using System.Windows;
using System.Globalization;

namespace MyPublisher.Windows.Controls.Primitives
{
    [ValueConversion(typeof(int), typeof(bool))]
    public class DataConverterIsPositiveNumber : IValueConverter
    {
        private static DataConverterIsPositiveNumber _instance;
        public static DataConverterIsPositiveNumber Instance
        {
            get
            {
                if (null == _instance)
                    _instance = new DataConverterIsPositiveNumber();
                return _instance;
            }
        }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int intValue = (int)value;
            return (intValue > 0 ? true : false);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool boolValue = (bool)value;
            return boolValue ? 1 : 0;
        }

        #endregion
    }
}
